/** Spell base class.
 *
 * A spell is a means to apply effects to mobiles or items. Spells do not have
 * a physical presence on the map, have no duration and are not entities.
 */
function Spell()
{
	this.name = "Spell";
	this.target = "self";
	this.range = 1;
}
Spell.prototype = {};
/** Create a new spell from a definition.
 *@param id The id of the spell.
 *@param params Optional parameters bag.
 */
Spell.newById = function(id, param)
{
	var ret = new Spell();
	ret.init.call(ret, spells[id]);
	ret.__baseId = id;
	ret.param = param;
	return ret;
}
/** Initialize the values of a spell.
 *
 * Below are the valid parameters for the property bag.
 * @param name The name of the spell.
 * @param getEffects A function that returns a list of effects that will be applied to the target by the spell.
 * @param apply Function to be called when the spell is applied to a target.
 */
Spell.prototype.init = function(bag)
{
	util.mix(this, bag);
}
/** Re-links handler methods from the base definition.
 */
Spell.prototype.fromRON = function()
{
	var def = spells[this.__baseId];
	for(var o in def)
	{
		if(def.hasOwnProperty(o) &&
			typeof(def[o]) === "function")
			this[o] = def[o];
	}
}
ron.registerCtor(Spell, "Spell");
